﻿@page
@{ Layout = "_Layout"; }

<el-card class="box-card">
    <el-form :inline="true" :size="euiSize">
        <el-form-item label="">
            <el-button :size="euiSize" plain type="primary" style="margin-left: 0px;" icon="el-icon-plus" v-on:click="btnAddClick">
                新增角色
            </el-button>
        </el-form-item>
    </el-form>
    <el-table :data="roles" :size="euiSize" style="width: 100%" :height="($(window).height() - 115)">
        <el-table-column label="#" :default-sort="{prop: 'createdDate', order: 'descending'}"
                         type="index"
                         width="60"
                         align="left">
            <template scope="scope">
                <span>{{ scope.$index + 1 }}</span>
            </template>
        </el-table-column>
        <el-table-column prop="roleName" sortable
                         label="角色名称">
        </el-table-column>
        <el-table-column prop="description"
                         label="备注">
        </el-table-column>
        <el-table-column width="288" label="被使用" prop="adminCount" sortable>
            <template slot-scope="scope">
                <div v-if="scope.row.adminCount>0">
                    <el-button size="mini" plain v-for="roleAdmin in scope.row.admins" v-on:click="btnAdminViewClick(roleAdmin.key)">{{ roleAdmin.value }}</el-button>
                </div>
                <span v-else>无</span>
            </template>
        </el-table-column>
        <el-table-column width="130" label="创建人" prop="createrName" sortable>
            <template slot-scope="scope">
                <el-button-group>
                    <el-link :underline="false" type="primary" v-on:click="btnAdminViewClick(scope.row.createrId)">{{scope.row.createrName}}</el-link>
                </el-button-group>
            </template>
        </el-table-column>
        <el-table-column width="150"
                         prop="createdDate" sortable
                         label="创建时间">
        </el-table-column>
        <el-table-column width="100" align="right">
            <template slot-scope="scope">
                <el-dropdown :show-timeout="0" placement="left">
                    <el-button icon="el-icon-arrow-left" size="mini" v-on:click.stop="return false">
                        操作
                    </el-button>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item icon="el-icon-edit" v-on:click.native="btnEditClick(scope.row)">修改</el-dropdown-item>
                        <el-dropdown-item icon="el-icon-delete" v-on:click.native="btnDeleteClick(scope.row)" style="color:red;" divided>删除</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </template>
        </el-table-column>
        @await Html.PartialAsync("_PartialTableEmpty")
    </el-table>
</el-card>

@section Scripts{
    <script src="/sitefiles/assets/js/admin/settings/administratorsRole.js" type="text/javascript"></script>
}